import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'dva';
import { List, message, Avatar, Spin } from 'antd';
import styles from './index.less';
import {TimeSpan} from '../../utils';
import moment from "moment";
import YanWorking from './indexya';
import YlianWorking from './indexyl';
import WziWorking from './indexwz';
var timeout = null;
const Pages = ({ account_working, dispatch, loading }) => {
    let {ID_1,ID_2,ID_3} = account_working;
    return (<div className={styles.container}>
        <h2 style={{marginLeft:20,display:(ID_1 || ID_2 || ID_3)?'none':'block'}}>内部工作工作流程</h2>
        <List
            style={{margin:40,display:(ID_1 || ID_2 || ID_3)?'none':'block'}}
            itemLayout="horizontal"
            dataSource={[
                {idState:'ID_1',title:'预案启动工作流',escription:"适用于预案启动流程",content:'预案负责人',none:'ID_2,ID_3'},
                {idState:'ID_2',title:'物资巡检',escription:"适于物资检查业务流程",content:'物资负责人',none:'ID_1,ID_3'},
                {idState:'ID_3',title:'预案演练工作流',escription:"适于预案演练工作流程",content:'演练计划负责人',none:'ID_1,ID_2'},
            ]}
            renderItem={item => (
                <List.Item>
                    <List.Item.Meta
                        avatar={<Avatar src="" />}
                        title={<a>{item.title}</a>}
                        description={item.escription}
                    />
                    <div style={{marginRight:300,width:100}}>
                        <span>启动流程</span>
                        <div>{item.content}</div>
                    </div>
                    <a onClick={()=>{
                        let none = item.none.split(",");
                        dispatch({type:"account_working/save",payload:{[item.idState]:true,[none[0]]:false,[none[1]]:false}});
                    }} style={{width:50}}>编辑</a>
                </List.Item>
            )}
        />
        {ID_1 && <YanWorking/>}
        {ID_2 && <WziWorking/>}
        {ID_3 && <YlianWorking/>}
    </div>);
};
Pages.propTypes = {
    account_working: PropTypes.object,
    loading: PropTypes.object,
    dispatch: PropTypes.func,
};

export default connect(({ account_working, loading }) => ({ account_working, loading }))(Pages);